<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <div class="contentsize">档案管理-档案待办</div>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <!-- <el-form ref="form" :model="form" label-width="auto" :inline="true" size="mini">
                    <el-form-item label="档案编号:">
                        <div style="width:170px">
                            <el-input v-model="form.dabh" placeholder="请输入档案编号"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="房屋地址:">
                        <div style="width:170px">
                            <el-input v-model="form.dz" placeholder="请输入房屋地址"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="所属事务:">
                        <div style="width:170px">
                            <el-select v-model="form.sssw" placeholder="请选择所属事务">
                                <el-option v-for="item in ssswlist" :key="item.code" :label="item.name" :value="item.code">
                                </el-option>
                            </el-select>
                        </div>
                    </el-form-item>
                    <el-form-item label="是否完结:">
                        <div style="width:170px">
                            <el-select v-model="form.zt" placeholder="请选择是否完结">
                                <el-option v-for="item in ztlist" :key="item.code" :label="item.name" :value="item.code">
                                </el-option>
                            </el-select>
                        </div>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSearch" icon="el-icon-search" class="searchcolor">查询</el-button>
                    </el-form-item>
                </el-form> -->
            </div>
            <div style="overflow: hidden">
                <div style="width: 100%; position: relative">
                    <div class="lxstyle">文件归档</div>
                    <div
                        style="
                            position: absolute;
                            width: calc(100% - 130px);
                            left: 130px;
                            top: 18px;
                            height: 1px;
                            background-color: #e8e9fb;
                        "
                    ></div>
                </div>
                <el-table
                    :data="tableData"
                    style="width: 100%"
                    :header-cell-style="tableHeaderColor"
                    :row-style="tablerowColor"
                    :row-class-name="tableRowClassName"
                    :cell-style="tablecellColor"
                    border
                >
                    <el-table-column prop="dabh" label="档案编号" align="center" width="240" :show-overflow-tooltip="true">
                    </el-table-column>
                    <el-table-column prop="dz" label="地址" align="center" width="280" :show-overflow-tooltip="true"> </el-table-column>
                    <el-table-column prop="addusername" label="发起人" align="center"> </el-table-column>
                    <el-table-column prop="sssw" label="所属事务" align="center"> </el-table-column>
                    <el-table-column label="操作" width="100" align="center">
                        <template slot-scope="scope">
                            <el-button type="text" size="small" @click="gotofwjg(scope.row.processcode, scope.row.id)">办理</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="pagination" style="float: right">
                    <el-pagination
                        background
                        layout="total,prev, pager, next,jumper"
                        :total="total"
                        :current-page.sync="current"
                        :page-size="pageSize"
                        @current-change="handleCurrentChange"
                    >
                    </el-pagination>
                </div>
            </div>
            <div style="overflow: hidden">
                <div style="width: 100%; position: relative">
                    <div class="lxstyle">数据归档</div>
                    <div
                        style="
                            position: absolute;
                            width: calc(100% - 130px);
                            left: 130px;
                            top: 18px;
                            height: 1px;
                            background-color: #e8e9fb;
                        "
                    ></div>
                </div>
                <el-table
                    :data="sjtableData"
                    style="width: 100%"
                    :header-cell-style="tableHeaderColor"
                    :row-style="tablerowColor"
                    :row-class-name="tableRowClassName"
                    :cell-style="tablecellColor"
                    border
                >
                    <el-table-column prop="bz" label="当前节点" align="center"> </el-table-column>
                    <el-table-column prop="sssw" label="所属事务名称" align="center"> </el-table-column>
                    <el-table-column prop="dz" label="地址" align="center" width="280" :show-overflow-tooltip="true"> </el-table-column>
                    <el-table-column prop="addusername" label="发起人" align="center"> </el-table-column>
                    <el-table-column prop="adddatetime" label="发起日期" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.adddatetime ? scope.row.adddatetime.split(' ')[0] : '' }}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="100" align="center">
                        <template slot-scope="scope">
                            <el-button type="text" size="small" @click="gotosjym(scope.row.processcode, scope.row.id)">办理</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="pagination" style="float: right">
                    <el-pagination
                        background
                        layout="total,prev, pager, next,jumper"
                        :total="sjtotal"
                        :current-page.sync="sjcurrent"
                        :page-size="pageSize"
                        @current-change="sjhandleCurrentChange"
                    >
                    </el-pagination>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { gdcaselist, dbnodelete, gddbnodelist } from '@/api/index';
import valueList from '@/components/common/valueList.vue';
export default {
    name: 'gdlist',
    data() {
        return {
            ssswlist: valueList.ssswlist, //所属事物列表
            total: 0,
            current: 1,
            sjtotal: 0,
            sjcurrent: 1,
            pageSize: 10,
            form: {
                adduser: this.$store.getters.userId,
                caseid: '', //流程实例id,
                create_name: '', //创建人,
                create_name_id: '', //创建人id,
                create_time: '', //创建时间,
                current: 1, // 第几页 ,
                fj: '', //归档附件 ,
                gdjl: '', //归档记录 ,
                id: '', //id ,
                pageSize: 10, // 每页数量 ,
                status_code: 1, // 1正常 2删除 ,
                update_name: '', //修改人 ,
                update_name_id: '', //修改人id ,
                update_time: '', //修改时间 ,
                zt: 0 //归档状态 0：待办 1：已办
            },
            gdform: {
                adddatetime: '', // 发起日期 ,
                adduser: '', // 发起人ID ,
                addusername: '', // 发起人姓名 ,
                bz: '', // 步骤（当前节点） ,
                current: 1, //第几页 ,
                dabh: '', // 档案编号 ,
                dz: '', // 地址 ,
                id: '', // id ,
                pageSize: 10, // 每页数量 ,
                processcode: '', // 流程模板编码(例：fwjg) 所属事务编码 ,
                sssw: '', // 所属事务名称 ,
                userid: this.$store.getters.userId // 当前用户ID
            },
            tableData: [],
            sjtableData: [], //数据归档
            ztlist: [
                { name: '是', code: 1 },
                { name: '否', code: 0 }
            ]
        };
    },
    components: {},
    computed: {},
    methods: {
        // 列表样式
        tableHeaderColor({ row, column, rowIndex, columnIndex }) {
            if (rowIndex === 0) {
                return 'background:linear-gradient(to bottom, #008A94,#0ae2f2)!important;color:#ffffff;font-size:14px;';
            }
        },
        tablerowColor({ row, rowIndex }) {
            return 'height: 42px;font-size:14px;color:black';
        },
        tablecellColor() {
            return 'font-weight:700;color:#000000;border-color:#c0c0c0';
        },
        tableRowClassName({ row, rowIndex }) {
            if (rowIndex % 2 != 0) {
                return 'success-row'; //这是类名
            } else {
                return '';
            }
        },
        // 换页
        handleCurrentChange(val) {
            this.current = val;
            this.form.current = val;
            this.gdcaselist(this.form);
            console.log(val);
        },
        // 换页
        sjhandleCurrentChange(val) {
            this.sjcurrent = val;
            this.gdform.current = val;
            this.gddbnodelist(this.gdform);
            console.log(val);
        },
        // 搜索
        onSearch() {
            this.current = 1;
            this.form.current = 1;
            this.gdcaselist(this.form);
            console.log('搜索');
        },

        // 项目列表
        gdcaselist(data) {
            gdcaselist(data).then((res) => {
                if (res.code == 200) {
                    this.tableData = res.data.records;
                    this.total = res.data.total;
                } else {
                    this.tableData = [];
                    this.total = 0;
                }
            });
        },
        // 数据归档列表
        gddbnodelist(data) {
            gddbnodelist(data).then((res) => {
                if (res.code == 200) {
                    this.sjtableData = res.data.records;
                    this.sjtotal = res.data.total;
                } else {
                    this.sjtableData = [];
                    this.sjtotal = 0;
                }
            });
        },
        // 跳转流程页面
        gotofwjg(val, id) {
            if (val == 'jlbqtht1' || val == 'jlbqtht2') {
                this.$router.push({
                    // name: val,
                    name: 'qthtgd',
                    params: {
                        id: id
                    }
                });
            } else {
                let firstThree = val.substring(0, 3); // 获取前三个字符
                let rest = val.substring(3); // 获取剩余的字符
                let name = firstThree == 'jlb' ? rest + 'gd' : val + 'gd';
                // let name = val + 'gd'
                this.$router.push({
                    name: name,
                    params: { id: id }
                });
            }
        },
        // 跳转数据归档页面
        gotosjym(val, id) {
            if (val == 'jlbqtht1' || val == 'jlbqtht2') {
                this.$router.push({
                    // name: val,
                    name: 'qthtval',
                    params: {
                        id: id
                    }
                });
            } else {
                let firstThree = val.substring(0, 3); // 获取前三个字符
                let rest = val.substring(3); // 获取剩余的字符
                let name = firstThree == 'jlb' ? rest + 'val' : val + 'val';
                // let name = val + 'val'
                this.$router.push({
                    name: name,
                    params: { id: id }
                });
            }
        }
    },
    mounted() {
        console.log(this.$store.getters);
        this.gdcaselist(this.form);
        this.gddbnodelist(this.gdform);
        console.log(valueList);
    }
};
</script>

<style scoped>
.container {
    overflow: hidden;
}

.crumbs {
    background-color: #fff;
    padding: 20px 20px;
}

.indexTitle {
    margin-bottom: 20px;
}

.contentsize {
    font-size: 18px;
    font-weight: 700;
}

.handle-box {
    overflow: hidden;
}

/* 新增按钮 */
.addcolor {
    margin-bottom: 10px;
}

.unloadTitle {
    text-align: left;
    padding-bottom: 10px;
    box-sizing: border-box;
    color: #606266;
}

.lxstyle {
    padding: 6px 20px;
    border: 1px #e8e9fb solid;
    width: 130px;
    box-sizing: border-box;
    border-radius: 20px;
    text-align: center;
    color: #008a94;
    box-shadow: 0 0 10px #e8e9fb;
    margin-bottom: 10px;
}
</style>
<style>
.success-row {
    background-color: #eaf3fb !important;
}
</style>
